Many changes and cleanup