code optimizations and beautifications