some refactorings. fixed broken tests. my computer seems to die soon, this is a backup checkin :)