Fixed key length bug, changed nomenclature, added some asserts