code cleanup, RAM optimization