Changed order of method definitions

Now related methods are closer together so
the code is a little easier to read.