Cleaned up code for newer khepri