Refactored a lot again