Clean up implementation of sys_exec, remove some magic constants