Fix a couple of bugs in modules and some style

Cherry-picked some stuff I apparently never PR'd from a month ago.  =/