Added proper logging system, other changes.