Fix application ID parsing, etc.

- Take out some old merge markers that messed up the code
- More complete null and empty string-checking for locations
- Check for id in 'application_number' or 'application_reference', in old and new schemas, respectively.