A bit more code tweaking/cleanup