Fixed file permissions. Re-jigged state module.