a little bit of cleanup and a bugfix