Fixed parent window error and some cosmetic changes.