Cleaning up the code and adding comments in the new functions. Removing old api file