Cleanup and refractoring of some code
Cleanup and refractoring of some code