Extract HAL classes to own module

(also use json instead of simplejson)