Fixing some logic bugs on libcernvm