Writing good libraries and frameworks is very, very hard to do and requires lots of experience. Even then, all of them suck, more or less. Mine too.
You can still divide your sources into two parts, one for game specific stuff and another for more generic functions which you could maybe reuse for another game. That won't add much additional effort but gives a result of more maintainable sources.