Region detection works, major cleanups (unix)