changed to the standard PHP exceptions where applicable.