Did some refactorization (hope I didnt break anything)
Even more refactorization