Lots of clean up in keystone. Starting to add unit tests