code refactored, removed unused code, some test changes and added commentary to some methods