fix memory allocation
Add quality layer id option