Slight improvements and optimizations; still working on it

Signed-off-by: Jack Huey kitskub@gmail.com