inline some functions and remove some branching
remove depth tracking for immediately closed objects