Fix error with precision. Add automatic precision calculation based on key size.