Crapload of Bug Fixes

Signed-off-by: Da Xue <dxue@dxue-pc.(none)>