Better placeholder handling, copy requires/class

Also added tests and refactored slightly