Updated documentation, cleaned up code