Code improvements and removed unused codes