Minor bug fix
Code optimizations.