Refactor package compilation, add support for .replace()