forgot includes and some bugfixes