Merge branches 'wip' and 'master' into wip
tidying up the code. removing global variable
more tidying up
Merge branches 'master' and 'wip'