Moved companion objects out of final class to allow usage inside and fix
other issues