Make all source writing functions const
Clean up source writing functions