Fixes as suggested by @anitsirc