restructuring lib/wpa heavily