Misc fix.

Hi! 

this is a couple of small fixes that i found during code review. please take a look. 

Thanks.