fix bug in constructor, and a few other things