Adjusted the resize function to work a little better.