Major refactoring. Added check for the consistency of resources ("libs"), fixing #2