Updated documentation, did some minor refactoring