Refactoring syscalls for efficiency