bug fix
separate alloc & finalizer; refactor metadata; code cleanup