Implemented cursor, some bugfixes