Various fixes

Looks like you're right. Your solution is better.