Added memory management system and fixed some APIs for Runnable