Added Apache license and performed some cleanup