Added logic to handle the different resize events.
Added some formatting fixes.