code cleanup and deadcode elimination