Simplify/optimize some basic functions