Code and style improvments