Refactoring, added more documentation (#7)