added porper type mapping, better logging