Bugfix - sometimes the cursor overflows -> safety check
Cleanup + doc