Few bug fixes

Signed-off-by: Ben Hawker <hawker.ben@gmail.com>