Fixed cursor

Fixed strange behavior of the cursor in the search function and the
remove function.