tidied cpu code, fixed bug in cpu average calculation