Removed C99 dependency
Slightly refactored