Various small optimizations

Signed-off-by: thisischris <c@ia.net>