Complete refactoring

The code is now way more c#-y and readable (i.e. switch() { case true:
… } is replaced by if() and similar stuff).