Speed and Security improvement

Speed of DPA is about 4x faster. To method were added check of range,
parameters etc.
The code is better arranged.