clean up code + interfaces, add lots of new functions