Fixed some little bugs (thanks to Clang static analyzer)