more crud functions and some bugfixes and cleaning