First implementation

seems to work properly, but there is still a problem with rebind and
memory move