Hive sample, bug fixes, tidying up