Improved the element removal code

Improved the element removal code. Even if a selection was present, the
last right clicked element is also removed