Big refactor and rewrite

Also added configuration via config.yml