getState now includes track id for easier polling

track_id is now part of the JSON of getState. This commit also extracts
getState out to a seperate file, making maintainance eaiser.