Stuffing code into functions

+Cleaner than master branch?