cleaned up code and fixed documentation