Cleaned up code
Finished cleaning code, moved code for apis to seperate files