Cleanup. not fully tested