Removed dependency on output buffering and fixed some minor issues
Fixed minor issue from last commit.