Working version. Still needs external query and monitor spawning.