fixed some small potential programming accidents