Refactored a bit and added wrap content processing but not tested as always.