General code cleanup and added pragma mark