Bug fixes and preconditions for partial functions