finished a4q4 functionality, TODO: documentation, code cleanup