Tried sorting out the attribute functions a bit, needs more testing