Refactored parsing functions and activity/sleep calls.