Changed pdata-length check in constructor

+ removed some duplicate code
+ some cosmetic cleanup