More globals and function intro

Added more global variables, also playing with functions a bit.