Added new functions for enhancements and some code clean up