Fixed ID bug and optimized code. (still)