Fix some of the bugs found by @shbhrsaha in pull request jasperproject:jasper-client#124