[WIP] refactoring. code clean up. document methods