pretty big refactoring and adding some stuff...