Self tuning

Add initial support for self-tuning