Reintroduced painting, fixed various bugs.