inline for space determination
more concise mappings
less variables, less state
remove unused variable
some minor improvements