Separate library code from grunt task

Just a first simple step into separating the library bits out from the grunt bits.