Code Updates to fix bugs and write better code