use longsparsearrays instead of hashmaps in that one place
proper null checks and closing of cursors everywhere