add q library
code cleanup