Add hashmap_clear + other minor fixes and cleanups