Removed not used code and optimized.