Finished. Would like to make the handling of qs better.