minor bugfix
some improvements
Attempted conflict resolution with Ben's changes