Removed unused code; turned some methods into functions