error handling improved + more documentation scattered throughout.