Fine tuning. TODO: improve realtime performance