Minor edge case bugfixes

Change-Id: Id1acf1312dd6fd997cc7ed727289e9d40516f5cb
Signed-off-by: Jeremy Ho <jujaga@gmail.com>