Minor updates

Some bugfixes and some extra code improvements