Minor optimizations (must TEST)
Adapted to newest libs
Minor optimizations
Added setVal