fixed small error introduced in 963df0d76832420e8e95c67bb15283f818a0c4d1 and some more cleanup