Better documentation, removed redundant code