Various changes.
Added option for undersampling.