refactored cleanup
added copyright