cleanup and better documentation