Cleaned up and added more documentation