added meta ordering and cleanup code