Improved rectangle packing algorithm