Small rearrangement on code, added support for changing video quality