some code cleanup, and attempt to find memoryleaks, but some are still present, sigh... again customdata related...