more functions, more comments, some cleanup

extended line/character manipulation, neccessary fail-saves
final cleanup

because this order makes more sense