Fix #1136, fix #1134, fix #1119

Signed-off-by: Ross Allan <rallanpcl@gmail.com>