Removed unused attributes and moved some related functions together