improved documentation and cleaned up