More code tidying, cursor position added