more new functions and cleanup