Various critical and subcritical bug fixes

Signed-off-by: Jack Harley <jackpharley@gmail.com>