improvements and setPiece() method

- CHG: code improvements
- CHG: if piece type is not defined, pType is (null) now
- CHG: renamed 'type' to 'class'