Fixed bug. Guys please tell me before editing the engine. Some of the
code looks wierd but its supposed to be that way. I fixed the bugs
again. Do not revert the changes.