Working version (except for garbage collection).