Various bug fixes

Hi, BooK.

Please find attached a few quick bug fixes and improvements.

Tom