Theme not compiled after change

Try to modify a theme and have it automatically compile, but it did not compile. Also did not compile using the Tools extension compile option. It has occasionally worked. Does anybody know why this is?

I would also be interested to know how Shopware keeps track of the latest version of a theme. I know there is a theme table and some config files, but how do the theme_config and asset functions get the correct theme?

Thanks.