ExecuteProcedure: bugfixes, better factoring