further writing & cleanup