Refactored everything

See #4