Adding eject support

Taken from peglers fork, merging impossible due to so many other changes