Removed trailing spaces.
Cleaned up the edit window code, made it much cleaner and pythonic.