various bug fixes

Signed-off-by: Tim Henderson <tim.tadh@gmail.com>