Cleaning up and adding documentation for new functions