Made some opmizations and deleted debug stuff