Several small code changes