Added check for core lib or throw exception

And minor formatting