Using this library to parse both tcx and gpx might be a better idea than writing a new gpx parser:
https://github.com/cjoakim/ggps
Eliminating 'laps' would be better too, since it is an artifact from the tcx format and not really relevant for almost all activities (except running laps at a track, but then does it really matter?). DB model would be simplified, etc.