New updates to code structuring with some bugs removed