Code refactoring (trailing spaces, formatting, Debug.Assert- still not working)