Added documentation, cleaned up tests and added return types