implement -compile, various bug fixes;