Fixing home and end in some cases, adding a bunch of function