Several fixes, new functions and parameter constraints