Merge pull request #183 from Henry-CF/stability

increase stability by fixing various bugs
rollback a regression introduced in previous commit
Signed-off-by: Henry Chen <hchen@vmware.com>