Implement queue based handling. Restructure into proper package.