added virtual_smartpal(?), code refactoring