some cleaning + adapter code