Cleaned up defunc code