Fix some errors spotted by Alexey. Thanks Alexey ;)