More refactoring, move Side to seperate file, make code more generic