Cleanups/sanity

Sanely reimplements couple of functions in granules.c