fix min/max macros, compiler warning
add macro to Makefile from merge
Use tree structure to manage regions

Large commit. Changes region management use 4-way tree, with
preliminary support for region-splitting.
fix fprintf
cleanup
fix quest-position generation