code cleanup
added memory monitor