Simplified all the code.