Sensor networks are becoming an important part of the IT landscape. Existing systems, however, are limited in two fundamental ways: lack of data independence, and poor integration with the higher layers of the data processing chain. In this paper we present SwissQM, a next generation architecture for sensor networks built to address these two limitations. SwissQM combines a virtual machine at the sensors with a powerful gateway as access point to the system. The flexibility of SwissQM opens up the doors to sensor networks with richer functionality, data model independence, optimised performance, and smooth integration into the rest of the architecture. SwissQM supports adaptability (e.g., push down strategies), multiple users and applications, high query turn-around, extensibility (e.g., user defined functionality), and optimised use of resources. The paper describes SwissQM, the features it provides, and examples of its use.