Overhaul based on amwapi