Minor bug-fixes in code